﻿namespace Fuse8.ContentManagementFramework.SystemFacade.Globalization
{
    public abstract class MoFileFinderWithSuccessor : IMoFilesFinder
    {
        private IMoFilesFinder _successor;

        public string GetPath(string name)
        {
            var path = GetConcrete(name);

            if (string.IsNullOrEmpty(path) && _successor != null)
            {
                path = _successor.GetPath(name);
            }

            return path;
        }

        protected abstract string GetConcrete(string name);

        public void SetSuccessor(IMoFilesFinder successor)
        {
            if (_successor == null)
            {
                _successor = successor;
            }
            else
            {
                _successor.SetSuccessor(successor);
            }
        }
    }
}